/**
 * Created by IntelliJ IDEA.
 * User: martlenn
 * Date: 24-Jan-2008
 * Time: 16:32:05
 */
package org.hkupp.db.accessors;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
/*
 * CVS information:
 *
 * $Revision$
 * $Date$
 */

/**
 * This class extends Modification_typeTableAccessor.
 *
 * @author Lennart Martens
 * @version $Id$
 */
public class Modification_type extends Modification_typeTableAccessor {

    public Modification_type(HashMap aData) {
        super(aData);
    }

    public Modification_type(ResultSet aRs) throws SQLException {
        super(aRs);
    }

    /**
     * Returns all known Modification_type objects from the DB in a HashMap,
     * keyed by type and with the Modification_type as value..
     *
     * @param aConn Connection to retrieve the Modification_types from.
     * @return  HashMap with the type as key, and the Modification_type as value.
     * @throws  SQLException when the database could not be contacted.
     */
    public static HashMap<String, Modification_type> getALlModification_types(Connection aConn) throws SQLException {
        HashMap result = new HashMap(2);
        Statement stat = aConn.createStatement();
        ResultSet rs = stat.executeQuery("select * from modification_type");
        while(rs.next()) {
            Modification_type mt = new Modification_type(rs);
            result.put(mt.getName(), mt);
        }
        return result;
    }

}
